// 创建游戏实例前的调试信息
console.log('游戏配置初始化...');

// 获取屏幕尺寸
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;

console.log('屏幕尺寸:', screenWidth, 'x', screenHeight);

const config = {
    type: Phaser.AUTO,
    width: screenWidth,
    height: screenHeight,
    parent: 'game-container',
    scale: {
        mode: Phaser.Scale.RESIZE,
        autoCenter: Phaser.Scale.CENTER_BOTH,
        width: screenWidth,
        height: screenHeight
    },
    physics: {
        default: 'arcade',
        arcade: {
            gravity: { y: 0 },
            debug: false
        }
    },
    scene: [BootScene, MenuScene, GameScene],
    render: {
        pixelArt: false,
        antialias: true,
        roundPixels: true,
        powerPreference: 'high-performance',
        willReadFrequently: true
    },
    backgroundColor: '#000000'
};

// 创建游戏实例
const game = new Phaser.Game(config);

// 游戏创建后的调试信息
game.events.on('ready', () => {
    console.log('游戏实例已创建');
});

// 添加错误处理
game.events.on('error', (error) => {
    console.error('游戏错误:', error);
});

// 监听窗口大小变化
window.addEventListener('resize', () => {
    const newScreenWidth = window.innerWidth;
    const newScreenHeight = window.innerHeight;
    
    // 更新游戏尺寸
    game.scale.resize(newScreenWidth, newScreenHeight);
    console.log('游戏尺寸已更新:', newScreenWidth, 'x', newScreenHeight);
}); 